﻿using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using IDAL;
using Model;

namespace DAL
{
    public class MO : BaseRepository<MOInfo>, IMO
    {
        #region 静态变量部分
        private const string PARM_MO_MOID = "@MOID";
        private const string PARM_MO_PRODUCTTYPEID = "@ProductTypeID";
        #endregion

        #region 数据检索部分
        public IList<MOInfo> LoadEntities()
        {
            return null;
        }

        /// <summary>
        /// Get an individual category based on a provided id
        /// </summary>
        /// <param name="categoryId">Category id</param>
        /// <returns>Details about the Category</returns>
        public MOInfo LoadEntity<T1>(T1 mOID)
        {
            SqlParameter parm = GetParameter();
            //Bind the parameter
            parm.Value = mOID;
            return ExcuteSqlToGetEntity("MO_selectbyID", parm);
        }
        #endregion

        #region 重写基类部分
        //-------------------------------------重写超类基础操作---------------------------------------------------------

        public override MOInfo GetEntityRecord(SqlDataReader rdr)
        {
            MOInfo pro = new MOInfo(rdr.GetValue(0).ToString(), rdr.GetValue(1).ToString());
            return pro;
        }

        public override MOInfo GetEntityRecord()
        {
            MOInfo pro = new MOInfo();
            return pro;
        }

        public override string GetInsertsp()
        {
            return "MO_Insert";
        }

        public override string GetUpdatesp()
        {
            return null;
        }

        public override string GetDeletesp()
        {
            return null;
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter Parm = new SqlParameter(PARM_MO_MOID, SqlDbType.NVarChar, 50);
            return Parm;
        }

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PARM_MO_MOID, SqlDbType.NVarChar, 50),
					new SqlParameter(PARM_MO_PRODUCTTYPEID, SqlDbType.NVarChar, 50),
                };
            return parms;
        }

        public override void SetParameters(MOInfo mo, params SqlParameter[] Parms)
        {
            Parms[0].Value = mo.MOID;
            Parms[1].Value = mo.ProductTypeID;
        }
        #endregion
    }
}
